<?php

class User extends Doctrine_Record {

    public function setTableDefinition() {
        $this->hasColumn('company_id', 'integer', 20);
        $this->hasColumn('username', 'string', 255);
        $this->hasColumn('password', 'string', 255);
        $this->hasColumn('name', 'string', 255);
        $this->hasColumn('surname', 'string', 255);
        $this->hasColumn('jobtitle', 'string', 255);
        $this->hasColumn('userlevel', 'integer', 1);
        $this->hasColumn('email', 'string', 255);
        $this->hasColumn('active', 'integer', 1);
        $this->hasColumn('sentemail', 'integer', 1);
        $this->hasColumn('rights', 'string', 1000);
    }
 
    public function setUp() {
        $this->actAs('Timestampable');
        $this->hasMany('Comment as Comments', array(
            'local' => 'id',
            'foreign' => 'user_id'
                )
        );
        $this->hasMany('Support as Supports', array(
            'local' => 'id',
            'foreign' => 'set_job_user_id'
                )
        );
        $this->hasMany('Support as Supports', array(
            'local' => 'id',
            'foreign' => 'manage_job_user_id'
                )
        );
        $this->hasMany('Support as Supports', array(
            'local' => 'id',
            'foreign' => 'creater_job_user_id'
                )
        );
        $this->hasMany('Act as Acts', array(
            'local' => 'id',
            'foreign' => 'user_id'
                )
        );
        $this->hasOne('Company', array(
            'local' => 'company_id',
            'foreign' => 'id',
            'onDelete' => 'CASCADE'
                )
        );
    }

}

